package com.starlink.controller.admin;

import com.github.pagehelper.PageInfo;
import com.starlink.common.PageQueryRequest;
import com.starlink.common.WebResponse;
import com.starlink.common.annotation.WebAccess;
import com.starlink.model.request.save.BookReadingRecordSaveRequest;
import com.starlink.model.vo.BookReadingRecordVO;
import com.starlink.service.BookReadingRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author zhanghong
 */
@RestController
@RequestMapping("/admin/record")
@Api(value = "【管理端】阅读记录模块", tags = {"【管理端】阅读记录模块"})
public class AdminBookReadingRecordController {

    @Autowired
    private BookReadingRecordService bookReadingRecordService;

    @WebAccess(login = true)
    @ApiOperation("分页查询阅读记录")
    @PostMapping("/pageQuery")
    public WebResponse<PageInfo<BookReadingRecordVO>> pageQuery(@SortDefault(sort = {"t1.create_time"}, direction = Sort.Direction.DESC) Pageable pageable,
                                                                @RequestBody PageQueryRequest request) {
        return WebResponse.build(bookReadingRecordService.pageQuery(null,pageable,request));
    }
}
